<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>嵌套分组与不记录分组</title>
</head>
<body>
    
</body>
<script>
    const url = `
        https://www.baidu.com
        http://1002661758qq.com
        http://Jimmy.com
    `
    let urls= []
    const reg = /https?:\/\/((\w+\.+)?\w+\.(com|cn|org))/ig
    console.log(reg.exec(url)[1])
    urls.push(reg.exec(url)[0])
   
    console.log(reg.lastIndex)
    console.log(reg.exec(url))
    console.log(reg.lastIndex)
    console.log(reg.exec(url))
    console.log(reg.lastIndex)
    for(i = 0;i<3;i++){
        urls.push(reg.exec(url)[1])
    }
    console.log(urls)
    // while(reg.lastIndex!=null){
    //     // urls.push(reg.exec(url)[0])
    // }
</script>
</html>